fix: quadlet generator emits diagnostics to stderr under systemd-analyze verify#29079
Conversation
Logf wrote to /dev/kmsg and only fell back to stderr when the kmsg write failed or -dryrun was set. As root the kmsg write succeeds, so nothing reached stderr and `sudo systemd-analyze --generators verify` (which captures stderr, not kmsg) showed no diagnostics, while the same command without sudo did. Write to /dev/kmsg best-effort for early-boot/journal capture AND always copy the same line to stderr so verify and interactive sudo runs surface the messages. Rootless behavior is unchanged. Fixes: podman-container-tools#28888 Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Honny1
left a comment
There was a problem hiding this comment.
LGTM, Just one style question.
| fmt.Fprintf(os.Stderr, "%s\n", line) | ||
| os.Stderr.Sync() | ||
| } | ||
| logToKmsg(line) |
There was a problem hiding this comment.
This function returns a bool value; should it be like this?:
| logToKmsg(line) | |
| _ :=logToKmsg(line) |
|
@mvanhorn Any updates on this? |
|
Thanks @Honny1, and sorry for the delay. Good call — since |
Logf now always writes to stderr, so the kmsg write is best-effort and its bool return is intentionally ignored. Make the discard explicit with `_ = logToKmsg(line)` per review, rather than leaving it implicit. Signed-off-by: mvanhorn <mvanhorn@gmail.com>
6e20b31 to
6d57281
Compare
|
Signed off the second commit (the first was already signed), DCO is green now. Thanks for the review! |
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
Honny1
left a comment
There was a problem hiding this comment.
LGTM
PTAL @podman-container-tools/podman-reviewers @podman-container-tools/podman-maintainers
|
LGTM. Test failure looks like temporary issue. |
|
Yes, Packit is unstable. |
|
failure is unrelated |
Running
sudo systemd-analyze --generators verify <unit>against a broken quadlet printed no generator diagnostics, even though the same command withoutsudo(andpodman-system-generator -dryrun) did. The cause is incmd/quadlet/main.go:Logfwrote each line to/dev/kmsgand only fell back to stderr when that write failed or-dryrunwas set. As root the kmsg write succeeds, so nothing was written to stderr, andsystemd-analyze verifycaptures stderr rather than kmsg.Logfnow writes to/dev/kmsgbest-effort (preserving the early-boot and journal logging that root services rely on atdaemon-reload) and additionally always copies the samequadlet-generator[pid]: ...line to stderr, sosystemd-analyze verifyand interactivesudoruns surface the diagnostics. Rootless behavior, where kmsg is unavailable, is unchanged.Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
git commit -s).Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?
Fixes #28888